<template>
  <div id="main"></div>
</template>

<script>
import { api_ruuqest } from "../../api/reports";
import * as echarts from "echarts";
import _ from "lodash";
export default {
  data() {
    return {
      echarsList: {},
      options: {
        title: {
          text: "用户来源",
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
            label: {
              backgroundColor: "#E9EEF3",
            },
          },
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        xAxis: [
          {
            boundaryGap: false,
          },
        ],
        yAxis: [
          {
            type: "value",
          },
        ],
      },
    };
  },
  mounted() {
    this.query();
  },
  methods: {
    async query() {
      let myChart = echarts.init(document.getElementById("main"));
      let rst = await api_ruuqest();
      if (rst.meta.status == 200) {
        let d = _.merge(rst.data, this.options);
        myChart.setOption(d);
      }
    },
  },
};
</script>

<style lang="less" scoped>
#main {
  width: 100%;
  height: 100%;
}
</style>